/**
 * 我的零件平台---修改设计的JS文件
 */

$(document).ready(function(){
	rightFormSubmit();//右侧细节设置修改提交
});

//根据零件类型加载我的零件库列表
function getMyPartList(partstype){ 
	  $.ajax({  
	        type : "POST",  
	        url : CONTEXT_PATH+'front/partDesign/getMyPartList?partsType='+partstype,  
	        dataType : "json",  
	        cache : false,  
	        async : false,  
	        success : function(data) {  
               $(".left-twoImgList.listImgBox").empty();
               
               for(i=0;i<data.length;i++){
                   $(".left-twoImgList.listImgBox").append(
       					"<div class='left-twoImgBlock leftImgBlock "+(data.id==$("#partsNo").val()? 'activeImg':'')+"'>"+
       					"<div class='left-twoImgBox'><img src='"+FILESERVER_PATH+"?id="+data[i].twoDid+"'/></div>"+
       					"<div class='left-oneImgName'>"+data[i].partsName+"</div>"+
       				        "<input type='hidden' value="+JSON.stringify(data[i])+">"+
       				    "</div>");
               }
               imgSelectControl();
               
	        }  
	    }); 
	
}

function rightFormSubmit(){
	$("#formSubmit").click(function(){
		$("#myPartsModifyModal").modal('show');
	});
	
}

var isSubmit = false;

function submitForm(id){
	   if (isSubmit) {  
	        return  
	   }  
	                  
	  var  url=CONTEXT_PATH+'front/partDesign/updateMyPartDesign';
	   	   
	   isSubmit = true;  
	   
	   $('#myPartDesignform').ajaxSubmit({
		    dataType: "json",  
		    url: url,
		    type : "POST",
		    success: function(data) {  
             if(data.result){
             	
             	 isSubmit = false;  
                  window.location.href= CONTEXT_PATH+'front/partDesign/partDesign_list';
             	
             }else{
            	 alert("修改失败！");
             }
		          
		    }   
		  
	  });  
}

function download(designid){
    
    $("#designid").val(designid);
    $("input[name='chose']").prop("checked",false);
	$("#loadModal").modal('show');
 
}

function submitDownload(){

	if ($("input[name='chose']:checked").length!=0) {
		$("#downloadForm").submit();
		$("#loadModal").modal('hide');
	}else{
		jAlert("请先至少选中一个","提示");
	}

}